perm filename AL.PAL[PNT,HE]3 blob sn#516916 filedate 1980-06-20 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.TITLE  AL INTERPRETER
C00006 00003	 program initialization
C00014 ENDMK
C⊗;
.TITLE  AL INTERPRETER

.OFFSET -160000		;Load us into the high mem: virtual 0 → physical 160 000
			;Comtab and dpatch area are in data space
.IFNDF CPOINTY
CPOINTY==0		; unless otherwise stated this is not a POINTY compilation
.ENDC

;These need only be looked at during the first pass:
    .IF1
        .INSRT ALHEAD.PAL[AL,HE]
        .INSRT K1DEF.PAL[11,SYS]
	STSW  KERNEL,1	;1 => use the kernel
    .ENDC

.OFFSET -340000		;Load us into the zonker: virtual 0 → physical 340 000
			;Start and ipatch area are in code space

	;If DDT sends us to user I space this will start the Kernel up anyway
. = START

	RESTRT		;EMT gets us into Kernel I space
	BPT
	BPT		;This is the INIT entry point to the Kernel

. = INTCOD
CODE$ == INTCOD		;Interpreter code & data spaces start here
DATA$ == INTDAT
SPSWITCH == 0		;Make sure we start off with everyone properly defined
DATA

.PRINT /	ALIO
/
.IFZ CPOINTY
.INSRT ALIO.PAL[AL,HE]
.ENDC
.IFNZ CPOINTY
.INSRT ALIO2.PAL[PNT,HE]
.ENDC

.PRINT /	LARGEB
/
.INSRT LARGEB.PAL[AL,HE]

			;Small block allocator
.PRINT /	SMALLB
/
.INSRT SMALLB.PAL[AL,HE]

			;The interpreter
.PRINT /	INTERP
/
.INSRT INTERP.PAL[AL,HE]

.IFNZ CPOINTY		; interpreter for pointy routines
.PRINT /	PINTRP
/
.INSRT PINTRP.PAL[PNT,HE]

			; display routines on the  VT05
.PRINT /	ALDISPLAY
/
.INSRT ALDISP.PAL[PNT,HE]

			; routines talking to the 10
.PRINT /	TALK10
/
.INSRT TALK10.PAL[PNT,HE]
.ENDC
			;The floating I/O
.PRINT /	FLOAT
/
    .INSRT FLOAT.PAL[AL,HE]

			;Graph structure
.PRINT /	GRAPHS
/
.INSRT GRAPHS.PAL[AL,HE]

DATA	;Data areas

MAINBL:: PDBLK 1,20	;Makes a process descriptor for main process
MAININ:: PDBLK 1,150,F	;Makes another PDB for the main (1st) interpreter

ISTBLK:: .BLKW ISBS	;Dummy interpreter status block (used in linking only)
PROLST:: .WORD 0	;List of procedures currently active
ALLIVE:: .WORD 0	;1 when AL is running, 0 otherwise

CODE
temp == %OFFSE	;Save the current offset
.OFFSET 0	;We want to use real physical addresses here for the kernel

	PUTLOC JOBDAT, MAINBL
	PUTLOC JOBSA, AL
	PUTLOC JOBDM, USRDM

.OFFSET temp	;Restore Offset
; program initialization

AL:	
	;initialize the world
	MOV USKMAX+MAINBL,SP	;Make sure we have a good stack pointer
	JSR PC,IOINIT	;Initialize input-output
	EVWAIT CSLEVT	;Grab the console
	MOV #STRMES,R0	;Print AL runtime system message
	JSR PC,TYPSTR
	EVSIG CSLEVT	;Release the console
	JSR PC,FRINIT	;Initialize free storage
	JSR PC,SBINIT	;Initialize small block space
	JSR PC,GSINIT	;Initialize graph structure
	CLR GCNT	;Counter for gathering force data
	;check to see that the PCODE is compatible
	CMP PCDVER,#PCVERSION	;Version compatible?
	BEQ 1$		;Yes
	ALERR STMES	;No
1$:	JSR PC,INIARM	; do arm initialization
	;set up the first interpreter
	JSR PC,INTINIT		;Initialize the interpreter events
	MOV #ISBS,R0		;R0 ← Size (in words) of an interpreter status block
	JSR PC,GTFREE		;R0 ← LOC[new interpreter status block]
	MOV R0,NXTINT+ISTBLK	;Prime the interpreter list.
	CLR NXTINT(R0)
	CLR PROLST		;Prime the active procedure list
	MOV #PCODE,IPC(R0)	;new IPC ← interpreter start address
	EVMAK			;-(SP) ← event for EVT in this interpreter
	MOV (SP),EVT(R0)	;new EVT ← event just created.
	MOV R0,-(SP)		;Save LOC[new interpreter status block]
	MOV #INSTSZ,R0		;R0 ← Size needed for an interpreter stack
	JSR PC,GTFREE		;R0 ← LOC[new interpreter stack]
	MOV (SP)+,R1		;R1 ← LOC[new interpreter status block]
	MOV R0,STKBAS(R1)	;Store away new stack base
	ADD #2*INSTSZ,R0	;R0 ← LOC[top of new stack] (INSTSZ is in bytes)
	MOV #MAININ,R2		;R2 ← LOC[main interpreter process descriptor]
	BIS #UGRSAV+USKSAV,PDBSTA(R2)	;Use saved registers so we can set things up
	MOV R0,PDBR3(R2)	;Store away new interp stack pointer (reg 3)
	MOV R2,PDB(R1)		;Store away LOC[PDB] in new ISB
	MOV R1,PDBR4(R2)	;Store away LOC[ISB] in reg 4 of PDB
	MOV USKMAX(R2),USKP(R2)	;Make sure we have a good stack pointer
	SCHEDU R2,#INTERP,#USRDM,#2 ;Cause the new process to be started, suspended
	MOV #1,ALLIVE		;Let rest of world know we are alive
	CMP #1,SAILID		;Is is a POINTY version?
	BNE 42$		;No, no need to start up POINTY
	JSR PC,UPDINIT		;Initialize the updating
	JSR PC,PNTINIT	;Yes, go initialize POINTY
42$:	EVWAIT 		;Wait for the return signal
	BCC  5$		;All well?
	ALERR TSTMES	;No
5$:	CMP #1,SAILID		;is it pointy?
	BNE 51$
	CLR ALLIVE	;done with the AL program
	SLEEP #1000.	;give a chance for all the other jobs to die
51$:	EVWAIT CSLEVT	;Grab the console
	MOV #ENDMES,R0	;Print ALL DONE message
	JSR PC,TYPSTR
	GETTIM		;Get current time from kernel
	CLRB 1(SP)	;So we don't lose the lower bits on conversion
	SETL		;Time is in long format
	LDCLF (SP)+,AC0	;AC0 ← time in msecs
	SETI		;Back to normal short integer format
	DIVF THOUS,AC0	;AC0 ← time in seconds
	MOV #OUTBUF,R0
	JSR PC,CVFX
	MOV #OUTBUF,R0
	JSR PC,TYPSTR	;Tell how long we took
	MOV #TIMMES,R0
	JSR PC,TYPSTR
	EVSIG CSLEVT	;Release the console
	DISMIS		;Go away


INIARM:	TST LINTARM	;For debugging new systems - if the arm code hasn't been
	BEQ 4$		; loaded then don't try to initialize the arm
	MOV #DVBKSZ,R0	;Get a device block
	JSR PC,GTFREE
	MOV R0,R1
	MOV R0,-(SP)	;Save address of device block so we can free it
	JSR PC,@LINTARM	;Initialize the arm code
	TST R0		;All well?
	BEQ 3$		;Yes
	CMP R0,#10	;Is it the reference supply?
	BNE 2$
	ALERR STMES3	; yup - complain about it.
	BR 3$
2$:	CMP R0,#7	;Is it the power supply?
	BNE 22$
	ALERR STMES4	; yup - complain about it.
	BR 3$
22$:	ALERR STMES2	;Just make a general complaint.
3$:	MOV (SP)+,R0	;R0 ← LOC[device block]
	JSR PC,RLFREE	;Release it
	CMP ARMVER,#VERSION	;Arm compatible?
	BEQ 4$		;Yes
	ALERR STMES1	;No
4$:	RTS PC

DATA
PNTMES:: ASCIE </CAN'T CONTINUE/>
STMES::  ASCIE </INCOMPATIBLE PCODE VERSION.  PROCEED AT YOUR OWN RISK/>
STMES1:: ASCIE </INCOMPATIBLE ARM VERSION.  PROCEED AT YOUR OWN RISK/>
STMES2:: ASCIE </CAN'T INITIALIZE ARM.  ERROR CODE IN R0./>
STMES3:: ASCIE </CAN'T INITIALIZE ARM.  REFERENCE POWER SUPPLY OUT OF RANGE./>
STMES4:: ASCIE </Can't initialize arm.  Interface power supply turned off/>
TSTMES:: ASCIE </BAD RETURN FROM MAIN INTERPRETER/>
STRMES:: ASCIE </
AL runtime system

/>
TIMMES:: ASCIE </ SECONDS
/>
ENDMES:: ASCIE </

ALL DONE NOW.  SEE YOU AROUND!
ELAPSED TIME = />

PUTLOC LGETARG, GETARG

DATEND == .		;Get end of data address

.IF2
DATA
CODE
	.INFO <First location after interpreter code = 340000 + >,\CODE$
	    .IFL 120000 - CODE$
	      .PRINT /Now need to dump above 460000 with 11TTY!
/
	    .ENDC
	    .IFL 140000 - CODE$
	      .ERROR Interpreter code too large for available memory!
	    .ENDC
	.INFO <Data ends at = >,\DATA$

	foo == <PCODE - DATEND - 3> / <4 * 60.>	; # of seconds we can gather
	.INFO <Gather buffer in seconds (base 8) = >,\foo
.ENDC

.END  START